<?php
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2015/12/11
 * Time: 15:47
 */

namespace Home\Model;
use Common\Model\CommonModel;

class UserModel extends CommonModel
{
     public function is_add($openid){
         $where['openid']=$openid;
         $res=$this->where($where)->find();
         return $res;
     }

    /**
     * 修改用户的积分
     * @param $userid  用户id
     * @param $point   操作的积分数
     * @param int $type 类型  添加或者减少
     */
     public function editPoint($userid,$point,$type=PointlogModel::ADD){
         $where['id']=$userid;
         $res=null;
         if($type==PointlogModel::ADD){//增加积分
             $res=$this->where($where)->setInc('jifen',$point);
         }else if($type==PointlogModel::DEC){//减少积分
             $res=$this->where($where)->setDec('jifen',$point);
         }
         echo $this->getLastSql();
         return $res;
     }
}